// 更新所有医院的属性名称
using Microsoft.EntityFrameworkCore;
using S.M.SmartMedical.Domain.Entities;

namespace S.M.SmartMedical.Infrastructure
{
    /// <summary>
    /// 数据库数据种子类，用于初始化基础数据
    /// </summary>
    public static class DataSeeder
    {
        /// <summary>
        /// 初始化医院测试数据
        /// </summary>
        /// <param name="context">数据库上下文</param>
        public static async Task SeedHospitalsAsync(MyDbContext context)
        {
            // 检查是否已有医院数据
            if (!await context.Hospitals.AnyAsync())
            {
                var hospitals = new List<Hospital>
                {
                    new Hospital
                    {
                        Name = "北京协和医院",
                        ImageUrl = "https://via.placeholder.com/300x200/4CAF50/ffffff?text=协和医院",
                        Level = "三甲",
                        Type = "综合医院",
                        Address = "北京市东城区帅府园1号",
                        Phone = "010-69156114",
                        Description = "北京协和医院是集医疗、教学、科研于一体的大型三级甲等综合医院",
                        IsEnabled = true,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    },
                    new Hospital
                    {
                        Name = "北京大学第一医院",
                        ImageUrl = "https://via.placeholder.com/300x200/2196F3/ffffff?text=北大医院",
                        Level = "三甲",
                        Type = "综合医院",
                        Address = "北京市西城区西什库大街8号",
                        Phone = "010-83572211",
                        Description = "北京大学第一医院创建于1915年，是我国最早的国立医院",
                        IsEnabled = true,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    },
                    new Hospital
                    {
                        Name = "复旦大学附属中山医院",
                        ImageUrl = "https://via.placeholder.com/300x200/FF9800/ffffff?text=中山医院",
                        Level = "三甲",
                        Type = "综合医院",
                        Address = "上海市徐汇区枫林路180号",
                        Phone = "021-64041990",
                        Description = "复旦大学附属中山医院是国家卫生健康委员会委属事业单位",
                        IsEnabled = true,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    },
                    new Hospital
                    {
                        Name = "四川大学华西医院",
                        ImageUrl = "https://via.placeholder.com/300x200/F44336/ffffff?text=华西医院",
                        Level = "三甲",
                        Type = "综合医院",
                        Address = "成都市武侯区国学巷37号",
                        Phone = "028-85422114",
                        Description = "华西医院起源于1892年，是西南地区最早的西医医院",
                        IsEnabled = true,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    },
                    new Hospital
                    {
                        Name = "中山大学附属第一医院",
                        ImageUrl = "https://via.placeholder.com/300x200/00BCD4/ffffff?text=中山一院",
                        Level = "三甲",
                        Type = "综合医院",
                        Address = "广州市越秀区中山二路58号",
                        Phone = "020-87755766",
                        Description = "中山大学附属第一医院是华南地区最大的综合性医院",
                        IsEnabled = true,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    },
                    new Hospital
                    {
                        Name = "华中科技大学同济医院",
                        ImageUrl = "https://via.placeholder.com/300x200/9C27B0/ffffff?text=同济医院",
                        Level = "三甲",
                        Type = "综合医院",
                        Address = "武汉市解放大道1277号",
                        Phone = "027-83662688",
                        Description = "华中科技大学同济医学院附属同济医院",
                        IsEnabled = true,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    },
                    new Hospital
                    {
                        Name = "浙江大学医学院附属第一医院",
                        ImageUrl = "https://via.placeholder.com/300x200/3F51B5/ffffff?text=浙大一院",
                        Level = "三甲",
                        Type = "综合医院",
                        Address = "杭州市上城区庆春路79号",
                        Phone = "0571-87236114",
                        Description = "浙江大学医学院附属第一医院是浙江省最大的综合性医院",
                        IsEnabled = true,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    },
                    new Hospital
                    {
                        Name = "中国医学科学院肿瘤医院",
                        ImageUrl = "https://via.placeholder.com/300x200/009688/ffffff?text=肿瘤医院",
                        Level = "三甲",
                        Type = "专科医院",
                        Address = "北京市朝阳区潘家园南里17号",
                        Phone = "010-67781331",
                        Description = "中国医学科学院肿瘤医院是国家癌症中心依托单位",
                        IsEnabled = true,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    }
                };

                await context.Hospitals.AddRangeAsync(hospitals);
                await context.SaveChangesAsync();
                
                Console.WriteLine("✅ 医院测试数据插入成功！共插入 {0} 家医院", hospitals.Count);
            }
            else
            {
                Console.WriteLine("ℹ️ 医院数据已存在，跳过插入");
            }
        }
    }
}